﻿#include "eventtimeout.h"
#include "ui_eventtimeout.h"
#include <QDateTime>
#include <QUrl>
EventTimeout::EventTimeout(QString name,int level,QWidget *parent) :
    QDialog(parent),
    ui(new Ui::EventTimeout) {
    ui->setupUi(this);
    this->name = name;
    if(level==1)ui->label_name->setStyleSheet("color:red;");
    ui->label_name->setText(name);

    ui->label_time->setText(QDateTime::currentDateTime().toString("HH:mm"));
    if(level==1) {
        this->player.setMedia(QUrl("qrc:/bellring/canno.mp3"));
        this->player.play();
    } else {
        this->tts.say(tr("time to")+name);
    }
}

EventTimeout::~EventTimeout() {
    delete ui;
}

void EventTimeout::on_pushButton_clicked() {
    this->player.stop();
    this->tts.stop();
    close();
    deleteLater();
}
